local wezterm = require 'wezterm'
local act = wezterm.action
local config = {}

local function append (tab)
  table.insert(config.keys, tab)
end


config.keys = {}

config.keys = {
  { key = 'h', mods = 'ALT', action = act.ActivateTabRelative(-1) },
  { key = 'l', mods = 'ALT', action = act.ActivateTabRelative(1) },
}

-- CTRL+ALT + number to move to that position
for i = 1, 8 do
  append({
    key = tostring(i),
    mods = 'ALT',
    action = act.MoveTab(i - 1),
  })
end

append ({ key = 'n', mods = 'ALT', action = act.SpawnTab 'CurrentPaneDomain' })
append ({ key = 'c', mods = 'ALT', action = act.CloseCurrentTab {confirm = true} })

-- wezterm.on ('change-wallpaper-random', function ()
--     local PATH_SEP = '\\'
--     local GLOB_PATTERN = '*.{jpg,jpeg,png,gif,bmp,ico,tiff,pnm,dds,tga}'
--     local files =
--         wezterm.glob(wezterm.config_dir .. PATH_SEP .. 'backdrops' .. PATH_SEP .. GLOB_PATTERN)
--         -- wezterm.glob(wezterm.config_dir .. PATH_SEP .. 'backdrops' .. PATH_SEP .. GLOB_PATTERN)
--     local current_idx = math.random(#files)
--     print(11111)
--     wezterm.GLOBAL.background = files[1]
-- end)
-- append ({ key = 'p', mods = 'ALT', action = act.EmitEvent "change-wallpaper-random" })

-- append ({
--     mods = 'SHIFT',
--     key = 'i',
--     action = wezterm.action_callback(function(win, pane)
--       wezterm.log_info 'Hello from callback!'
--       wezterm.log_info(
--         'WindowID:',
--         win:window_id(),
--         'PaneID:',
--         pane:pane_id()
--       )
--     end)
-- })

-- append(
--   { key = 'a', modes = 'ALT', action = act.ActivateTabRelative(1)}
-- )

return config
